package com.avantis.common.entity.base;

import com.avantis.common.utils.DateUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.util.Date;

/**
 * @Author: tracywang
 * @Date: 2019/2/12
 * @Descrption:
 */
@Data
@MappedSuperclass
public class BaseEntity {

    @Id
    @GenericGenerator(name="jpa-uuid", strategy="uuid")
    @GeneratedValue(generator="jpa-uuid")
    @Column(length = 32)
    private String id;

    /**
     * 行状态
     * 1：无效；0：有效
     * 默认为有效
     */
    @Column(nullable = false)
    private Integer rowStatus = 0;

    @Column
    @JsonFormat(pattern = DateUtils.DEFAULT_DATETIME_FORMAT, timezone = "GMT+8")
    private Date initTime;

    @Column
    @CreatedDate
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    private Date createdon;

    /**
     * 创建人
     */
    @Column
    private String creater;

    /**
     * 修改时间
     */
    @Column
    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    private Date modifyon;

    /**
     * 修改人
     */
    @Column
    private String modifier;

    @Version
    private Integer version;
}
